package com.chenxiao.field.fielddemo.controller;

import com.chenxiao.field.fielddemo.anno.FieldStyle;
import com.chenxiao.field.fielddemo.entity.User;
import com.chenxiao.field.fielddemo.service.UserService;
import com.chenxiao.field.fielddemo.utils.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: CX
 * @Date: Created in  2023/12/02 23:44
 * @version: v1.0
 * @Description: TODO
 **/
@RestController
public class UserController {
    @Resource
    private UserService userService;
    @GetMapping("/list")
    public AjaxResult queryOrderList(){
        List<User> orderDto = userService.list();
        return new AjaxResult("200",orderDto);
    }
    @PostMapping("/add")
    public AjaxResult add(@RequestBody User user){
        userService.save(user);
        return new AjaxResult("200","成功");
    }

}
